//
//  KZCategoryView.m
//  xiaorizi
//
//  Created by kun on 15/10/26.
//  Copyright © 2015年 origin. All rights reserved.
//

#import "KZCategoryView.h"
#import "UIImageView+WebCache.h"

@interface KZCategoryView ()
@property (weak, nonatomic) IBOutlet UILabel *titleLable;
@property (weak, nonatomic) IBOutlet UIImageView *themeImgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgConstraint;

@end

@implementation KZCategoryView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


+(KZCategoryView*)categoryView
{
    NSString *className = NSStringFromClass([self class]);
    return [[[NSBundle mainBundle]loadNibNamed:className owner:self options:nil]lastObject];
}


-(void)setModel:(CategoryEventModel *)model
{
    
    [_themeImgView sd_setImageWithURL:[NSURL URLWithString:model.img]];
    _titleLable.text = model.name;
}


-(void)willMoveToSuperview:(UIView *)newSuperview
{
    CGFloat appvieww= (newSuperview.bounds.size.width - 16)/3;
    CGFloat appviewh= appvieww*0.8 *0.8;
    self.imgConstraint.constant = appviewh;
    
    [self needsUpdateConstraints];
}



@end
